home *** CD-ROM | disk | FTP | other *** search
/ Oh!X 2001 Spring / Oh!X 2001 Spring Special CD-ROM (Japan) (Track 1).bin / JAVA / jshooting1 / jshooting.java < prev    next >
Encoding:
Java Source  |  2000-08-13  |  955 b   |  37 lines

  1. import java.applet.Applet;
  2. import java.awt.*;
  3.  
  4. public class jshooting extends Applet {
  5.     static final int WIDTH = 240, HEIGHT = 320;    // 背景サイズ
  6.     SpriteControl sc;    // スプライトコントロール
  7.     MediaTracker mt;
  8.     public void init(){
  9.         sc = new SpriteControl( 1, 1, WIDTH, HEIGHT, this );
  10.         mt = new MediaTracker( this );
  11.         Image image = getImage( getDocumentBase(), "img/back.gif" );    // 背景
  12.         mt.addImage( image, 0 );
  13.         sc.SetBGImage( image );
  14.         image = getImage( getDocumentBase(), "img/myship.gif" );    // 自機
  15.         mt.addImage( image, 0 );
  16.         sc.Define( 0, image );
  17.         sc.Set( 0, 0 );
  18.         sc.Move( 0, (WIDTH-32)/2, (HEIGHT-32)/2 );
  19.         sc.Show();
  20.         try {
  21.             mt.waitForID( 0 );
  22.         } catch( InterruptedException e ){
  23.             return;
  24.         }
  25.     }
  26.     public void update( Graphics g ){
  27.         paint( g );
  28.     }
  29.     public void paint( Graphics g ){
  30.         if( mt.checkID( 0 ) ){
  31.             sc.Display( g, this );
  32.         } else {
  33.             g.drawString( "Loading...", 0, 12 );
  34.         }
  35.     }
  36. }
  37.